home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML Authority.sea / XML Authority / Required / ccs_util.jar / test / ui / TraceFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-12-09  |  6.1 KB  |  193 lines

  1. package test.ui;
  2.  
  3. import java.awt.Button;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Frame;
  7. import java.awt.GridBagConstraints;
  8. import java.awt.GridBagLayout;
  9. import java.awt.Insets;
  10. import java.awt.SystemColor;
  11. import java.awt.TextArea;
  12. import java.awt.Window;
  13. import java.awt.event.ActionEvent;
  14. import java.awt.event.ActionListener;
  15. import java.awt.event.WindowEvent;
  16. import java.awt.event.WindowListener;
  17. import java.io.PrintWriter;
  18. import java.io.StringWriter;
  19. import java.lang.reflect.Constructor;
  20. import java.util.EventObject;
  21.  
  22. class TraceFrame extends Frame implements ActionListener, WindowListener {
  23.    private Button ivjCloseButton;
  24.    private TextArea ivjStackTextArea;
  25.    // $FF: synthetic field
  26.    static Class class$java$awt$Window;
  27.  
  28.    public TraceFrame() {
  29.       this.initialize();
  30.    }
  31.  
  32.    public TraceFrame(String title) {
  33.       super(title);
  34.    }
  35.  
  36.    public void actionPerformed(ActionEvent e) {
  37.       if (((EventObject)e).getSource() == this.getCloseButton()) {
  38.          this.conn1(e);
  39.       }
  40.  
  41.    }
  42.  
  43.    private void conn0(WindowEvent arg1) {
  44.       try {
  45.          ((Frame)this).dispose();
  46.       } catch (Throwable ivjExc) {
  47.          this.handleException(ivjExc);
  48.       }
  49.  
  50.    }
  51.  
  52.    private void conn1(ActionEvent arg1) {
  53.       try {
  54.          ((Frame)this).dispose();
  55.       } catch (Throwable ivjExc) {
  56.          this.handleException(ivjExc);
  57.       }
  58.  
  59.    }
  60.  
  61.    private Button getCloseButton() {
  62.       if (this.ivjCloseButton == null) {
  63.          try {
  64.             this.ivjCloseButton = new Button();
  65.             this.ivjCloseButton.setName("CloseButton");
  66.             this.ivjCloseButton.setLabel("Close");
  67.          } catch (Throwable ivjExc) {
  68.             this.handleException(ivjExc);
  69.          }
  70.       }
  71.  
  72.       return this.ivjCloseButton;
  73.    }
  74.  
  75.    private TextArea getStackTextArea() {
  76.       if (this.ivjStackTextArea == null) {
  77.          try {
  78.             this.ivjStackTextArea = new TextArea();
  79.             this.ivjStackTextArea.setName("StackTextArea");
  80.             this.ivjStackTextArea.setRows(10);
  81.             this.ivjStackTextArea.setColumns(60);
  82.          } catch (Throwable ivjExc) {
  83.             this.handleException(ivjExc);
  84.          }
  85.       }
  86.  
  87.       return this.ivjStackTextArea;
  88.    }
  89.  
  90.    private void handleException(Throwable exception) {
  91.    }
  92.  
  93.    private void initConnections() {
  94.       ((Window)this).addWindowListener(this);
  95.       this.getCloseButton().addActionListener(this);
  96.    }
  97.  
  98.    private void initialize() {
  99.       GridBagConstraints constraintsStackTextArea = new GridBagConstraints();
  100.       GridBagConstraints constraintsCloseButton = new GridBagConstraints();
  101.       ((Component)this).setName("TraceFrame");
  102.       ((Component)this).setName("TraceFrame");
  103.       ((Container)this).setLayout(new GridBagLayout());
  104.       ((Component)this).setBackground(SystemColor.control);
  105.       ((Component)this).setSize(403, 236);
  106.       ((Frame)this).setTitle("Stack Trace");
  107.       constraintsStackTextArea.gridx = 0;
  108.       constraintsStackTextArea.gridy = 0;
  109.       constraintsStackTextArea.gridwidth = 1;
  110.       constraintsStackTextArea.gridheight = 1;
  111.       constraintsStackTextArea.fill = 1;
  112.       constraintsStackTextArea.anchor = 10;
  113.       constraintsStackTextArea.weightx = (double)1.0F;
  114.       constraintsStackTextArea.weighty = (double)1.0F;
  115.       constraintsStackTextArea.insets = new Insets(8, 8, 8, 8);
  116.       ((GridBagLayout)((Container)this).getLayout()).setConstraints(this.getStackTextArea(), constraintsStackTextArea);
  117.       ((Container)this).add(this.getStackTextArea());
  118.       constraintsCloseButton.gridx = 0;
  119.       constraintsCloseButton.gridy = 1;
  120.       constraintsCloseButton.gridwidth = 1;
  121.       constraintsCloseButton.gridheight = 1;
  122.       constraintsCloseButton.anchor = 13;
  123.       constraintsCloseButton.weightx = (double)0.0F;
  124.       constraintsCloseButton.weighty = (double)0.0F;
  125.       constraintsCloseButton.insets = new Insets(0, 8, 8, 8);
  126.       ((GridBagLayout)((Container)this).getLayout()).setConstraints(this.getCloseButton(), constraintsCloseButton);
  127.       ((Container)this).add(this.getCloseButton());
  128.       this.initConnections();
  129.    }
  130.  
  131.    public static void main(String[] args) {
  132.       try {
  133.          TraceFrame aTraceFrame = new TraceFrame();
  134.  
  135.          try {
  136.             Class aCloserClass = Class.forName("uvm.abt.edit.WindowCloser");
  137.             Class[] parmTypes = new Class[]{class$java$awt$Window != null ? class$java$awt$Window : (class$java$awt$Window = class$("java.awt.Window"))};
  138.             Object[] parms = new Object[]{aTraceFrame};
  139.             Constructor aCtor = aCloserClass.getConstructor(parmTypes);
  140.             aCtor.newInstance(parms);
  141.          } catch (Throwable var6) {
  142.          }
  143.  
  144.          ((Component)aTraceFrame).setVisible(true);
  145.       } catch (Throwable var7) {
  146.          System.err.println("Exception occurred in main() of java.awt.Frame");
  147.       }
  148.  
  149.    }
  150.  
  151.    public void showTrace(Throwable t) {
  152.       StringWriter stringWriter = new StringWriter();
  153.       PrintWriter writer = new PrintWriter(stringWriter);
  154.       t.printStackTrace(writer);
  155.       StringBuffer buffer = stringWriter.getBuffer();
  156.       this.getStackTextArea().setText(buffer.toString());
  157.    }
  158.  
  159.    public void windowActivated(WindowEvent e) {
  160.    }
  161.  
  162.    public void windowClosed(WindowEvent e) {
  163.    }
  164.  
  165.    public void windowClosing(WindowEvent e) {
  166.       if (((EventObject)e).getSource() == this) {
  167.          this.conn0(e);
  168.       }
  169.  
  170.    }
  171.  
  172.    public void windowDeactivated(WindowEvent e) {
  173.    }
  174.  
  175.    public void windowDeiconified(WindowEvent e) {
  176.    }
  177.  
  178.    public void windowIconified(WindowEvent e) {
  179.    }
  180.  
  181.    public void windowOpened(WindowEvent e) {
  182.    }
  183.  
  184.    // $FF: synthetic method
  185.    static Class class$(String class$) {
  186.       try {
  187.          return Class.forName(class$);
  188.       } catch (ClassNotFoundException forName) {
  189.          throw new NoClassDefFoundError(((Throwable)forName).getMessage());
  190.       }
  191.    }
  192. }
  193.